package creational_pattern.factory.simple_factory;

/**
 * 咖啡的工厂类
 *
 */

public class CoffeeFactory {

    public Coffee createCoffee(String coffeeType) {
        Coffee coffee = null;
        if ("american".equals(coffeeType)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(coffeeType)) {
            coffee = new LatteCoffee();
        }else {
            throw new RuntimeException("Invalid coffee type");
        }
        return coffee;
    }
}
